<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			var arr = [];
			var index = 0;
			var flag = true;

			function addStu() {
				var stuNo = prompt("请输入学号");
				var stuName = prompt("请输入姓名");
				var stu = [];
				stu[0] = stuNo;
				stu[1] = stuName;
				arr[index] = stu;
				index++;
			}
			var a = prompt("1.登录2.退出");
			switch (a) {
				case "1":
					//登录
					do {
						var name = prompt("请输入用户名");
						var password = prompt("请输入密码");
						if (name === "tom" && password === "123") {
							break;
						}
					} while (true);
					//系统功能
					do {
						var b = prompt("1.添加2.删除3.遍历4.修改5.退出");
						switch (b) {
							case "1":
								addStu();
								break;
							case "2":
								var delNo = prompt("请输入要删除的学生学号");
								for (var k = 0; k < arr.length; k++) {
									if (arr[k][0] == delNo) {
										arr[k] = null;
										break;
									}
								}
								break;
							case "3":
								for (var i = 0; i < arr.length; i++) {
									if (arr[i] != null) {
										alert(arr[i]);
									}
								}
								break;
							case "4":
								var updateNo = prompt("请输入要修改的学生学号");
								var updateName = prompt("请输入要修改的学生姓名");
								for (var j = 0; j < arr.length; j++) {
									if (arr[j][0] == updateNo) {
										arr[j][1] = updateName;
										break;
									}
								}
								break;
							case "5":
								flag = false;
								break;
						}
					} while (flag);
					break;
				case "2":
					break;
			}
			alert("欢迎下次再用");
		</script>
	</head>
	<body>
	</body>
</html>
